#pragma once
#include <vector>
#include <string>
#include <functional>
namespace Test {
	class Test 
	{
	public:
		Test() {}
		~Test() {}
		virtual void Enter(){}
		virtual void Leave(){}
		virtual void OnRender(){}
		virtual void OnImguiRender(){}
		virtual void Update(float deltaTime){}
	};

	class TestMenu :public Test 
	{
	public:
		TestMenu(Test*& testPointer,bool* bEnterTest);
		~TestMenu();
		virtual void OnImguiRender() override;
		//Register Function Use for add Test to Container
		template<typename T>
		void RegiterTest(const std::string& name) {
			m_TestsContainer.push_back(std::make_pair(name, []() {return new T(); }));
		}
		void UnRegiterTest(const std::string& name) {

			auto removeIter = m_TestsContainer.end();
			for (auto iter = m_TestsContainer.begin(); iter != m_TestsContainer.end();++iter)
			{
				if (iter->first == name)
				{
					removeIter = iter;
				}
			}
			if (removeIter!=m_TestsContainer.end())
			{
				m_TestsContainer.erase(removeIter);
			}

		}
	private:
		Test*& m_currentTest;
		bool* m_bEnterTest;
		std::vector<std::pair<std::string, std::function<Test* ()>>> m_TestsContainer;
	};
}